package com.ljf.common.core;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * 自动填充配置
 *
 * @author LJF
 * @since 2024-05-01
 */
@Component
public class MyMetaObjectHandler implements MetaObjectHandler {

    @Override
    public void insertFill(MetaObject metaObject) {
        metaObject.setValue("creatorId", "");
        metaObject.setValue("createTime", new Date());
        metaObject.setValue("modifierId", "");
        metaObject.setValue("modifyTime", new Date());
        metaObject.setValue("version", 1);
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        metaObject.setValue("modifierId", "");
        metaObject.setValue("modifyTime", new Date());
    }

}
